#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e6 + 5;

int n, p, k;
int a[N];
ll prod[N];
ll inva[N];
ll fastpow(ll b, ll p, ll mod) {
  ll res = 1;
  while (p) {
    if (p & 1) res = res * b % mod;
    b = b * b % mod;
    p >>= 1;
  }
  return res;
}
template <class T>
T read(T &x) {
  x = 0;
  char ch = 0;
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read(n), read(p), read(k);
  rep(i, 1, n) read(a[i]);

  prod[0] = 1, a[0] = 1;
  rep(i, 1, n) prod[i] = prod[i - 1] * a[i] % p;

  ll x = fastpow(prod[n], p - 2, p);
  per(i, n, 1) {
    inva[i] = x * prod[i - 1] % p;
    x = x * a[i] % p;
  }

  x = 1;
  ll sum = 0;
  rep(i, 1, n) x = x * k % p, sum += x * inva[i] % p;
  sum %= p;
  cout << sum;
  return 0;
}